<?php
	if (isset($_SERVER['SCRIPT_FILENAME']) && 'comments.php' == basename($_SERVER['SCRIPT_FILENAME']))
		die ('请不要直接加载该页面，谢谢！');
	
	if ( post_password_required() ) { ?>
		<p class="nocomments"><?php _e('这篇文章需要密码，请输入密码访问'); ?></p> 
	<?php
		return;
	}
?>

     <script type="text/javascript"> 
	var defaultAuthor = "称呼(必填)";
	var defaultEmail = "邮箱(不会被公开,必填)";
	var defaultUrl = "网站";
	var defaultComment = "评论内容...";
	
	function commentform_submit(){
		if(document.commentform.author.value == '' || document.commentform.author.value == defaultAuthor) {alert('咳咳...称呼忘填了');document.commentform.author.focus();return;}
		if(document.commentform.email.value == '' || document.commentform.email.value == defaultEmail) {alert('email...您的email没填');document.commentform.email.focus();return;}
		if(document.commentform.comment.value == '' || document.commentform.comment.value == defaultComment) {alert('评论内容在哪？');document.commentform.comment.focus();return;}
		if(document.commentform.url.value == defaultUrl) document.commentform.url.value = '';
		// document.commentform.submit();
	}
	</script>

<?php if ( have_comments() ) : ?>
	<ol class="commentlist">
			<?php wp_list_comments('type=all&callback=mytheme_comment'); ?>
	</ol>
	
	<?php /* if ((int) get_option('page_comments') === 1 && get_comment_pages_count() > 1) { ?>
	<div class="navigation"><?php paginate_comments_links(); ?></div><span id="cp_post_id" style="display:none;"><?php echo $post->ID; ?></span>
	<?php } */ ?>

	<div class="pagenavi"><?php paginate_comments_links('prev_text=上一页&next_text=下一页');?></div>
 <?php else : ?>
	<?php if ('open' == $post->comment_status) : ?>
	<?php else : ?>
		<p class="nocomments">抱歉，暂停评论。</p>
	<?php endif; ?>
<?php endif; ?>

<div class="clear"></div>

<?php /* if ( comments_open() ) : ?>

	<?php if ( get_option('comment_registration') && !is_user_logged_in() ) : ?>

		<p><?php printf(__('你需要 <a href="%s">登录</a> 才可以回复.'), wp_login_url( get_permalink() )); ?></p>

	<?php else : ?>

		<div class="commentform" id="respond">
			<form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" name="commentform" id="commentform">
				<h4>发表评论 <a href="#top" class="back_top"></a></h4>

				<ul>
					<li class="cancel-comment-reply"><small><?php cancel_comment_reply_link(); ?></small></li>
				<?php if ( is_user_logged_in() ) : ?>
				
					<li class="smilies"><?php printf(__('当前您登录的用户名为 <a href="%1$s">%2$s</a>，'), get_option('siteurl') . '/wp-admin/profile.php', $user_identity); ?> <a href="<?php echo wp_logout_url(get_permalink()); ?>" title="<?php _e('Log out of this account'); ?>"><?php _e('退出 &raquo;'); ?></a></li>
					<input name="author" type="hidden" class="input" value="ilover" onfocus="if(this.value==defaultAuthor)this.value='';" onblur="if(this.value==''){this.value=defaultAuthor;}">
					<input name="email" type="hidden" class="input" value="admin@ilover.me" onfocus="if(this.value==defaultEmail)this.value='';" onblur="if(this.value==''){this.value=defaultEmail;}">
					<input name="url" type="hidden" class="input" value="http://www.ilover.me" onfocus="if(this.value==defaultUrl)this.value='';" onblur="if(this.value==''){this.value=defaultUrl;}">

				<?php else : ?>

					 <li><input name="author" type="text" class="input" value="称呼(必填)" onfocus="if(this.value==defaultAuthor)this.value='';" onblur="if(this.value==''){this.value=defaultAuthor;}"><span class="login_register"><a href="<?php bloginfo('home') ?>/wp-login.php?redirect_to=<?php the_permalink() ?>">登录</a> | <a href="<?php bloginfo('home') ?>/wp-login.php?action=register">注册</a></span></li>
					 <li><input name="email" type="text" class="input" value="邮箱(不会被公开,必填)" onfocus="if(this.value==defaultEmail)this.value='';" onblur="if(this.value==''){this.value=defaultEmail;}"></li>
					 <li><input name="url" type="text" class="input" value="网站" onfocus="if(this.value==defaultUrl)this.value='';" onblur="if(this.value==''){this.value=defaultUrl;}"></li>

				<?php endif; ?>
					 <li><textarea name="comment" id="comment" cols="" rows="" onfocus="if(this.value==defaultComment)this.value='';" onblur="if(this.value==''){this.value=defaultComment;}" onpropertychange="if(value.length&gt;1000) value=value.substr(0,1000)">评论内容...</textarea></li>
					 <!--li class="bnt"><a onfocus="this.blur()" href="javascript:commentform_submit();">发&nbsp;表</a></li><li-->
					 <input name="submit" type="submit" id="submit" tabindex="5" value="提 交" /><?php comment_id_fields(); ?>
					 <input type="hidden" id="comment_parent" name="comment_parent" value="0">
				</ul>

				<?php do_action('comment_form', $post->ID); ?>
			</form>
		</div>
		
	<?php endif; ?>

<?php endif; */ ?>

<?php if ('open' == $post->comment_status) : ?>
	<div id="respond" class="commentform">
		<h3><?php comment_form_title( '发表评论', '发表评论到 %s' ); ?></h3>
		<div class="cancel-comment-reply"><?php cancel_comment_reply_link(); ?></div>
		<?php if ( get_option('comment_registration') && !$user_ID ) : ?>
				<p>您需要 <a href="<?php echo get_option('siteurl'); ?>/wp-login.php?redirect_to=<?php echo urlencode(get_permalink()); ?>">登录</a> 才能评论.</p>
		<?php else :  ?>
		<form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform">
		
			<?php if ( $user_ID ) : ?>
			<p>登录用户为 <a href="<?php echo get_option('siteurl'); ?>/wp-admin/profile.php"><?php echo $user_identity; ?></a>. <a href="<?php echo wp_logout_url(get_permalink()); ?>" title="注销此用户">登出 &raquo;</a></p>
			<?php else : ?>
			<p><input type="text" name="author" id="author" value="<?php echo $comment_author; ?>" size="22" tabindex="1" />
			<label for="author"><small>称呼 <?php if ($req) echo "(必填)"; ?></small></label></p>
			<p><input type="text" name="email" id="email" value="<?php echo $comment_author_email; ?>" size="22" tabindex="2" />
			<label for="email"><small>邮箱 <?php if ($req) echo "(不会被公开,必填)"; ?></small></label></p>
			<p><input type="text" name="url" id="url" value="<?php echo $comment_author_url; ?>" size="22" tabindex="3" />
			<label for="url"><small>网站</small></label></p>
			<?php endif; ?>
			<p><textarea name="comment" id="comment" cols="100%" rows="6" tabindex="4" onkeydown="if(event.ctrlKey&amp;&amp;event.keyCode==13){document.getElementById('submit').click();return false};"></textarea></p>
			<p><input name="submit" type="submit" id="submit" tabindex="5" value="提交" /><?php comment_id_fields(); ?></p>
			<?php do_action('comment_form', $post->ID); ?>
			
		</form>
		<?php endif; ?>
		
	</div>
	
<?php endif; ?>
